//
//  AppDelegate.m
//  TodayComment
//
//  Created by 张吉阳 on 15/9/12.
//  Copyright (c) 2015年 xianrenmoshi. All rights reserved.
//

#import "AppDelegate.h"
#import "HomePage.h"
#import "WMCommon.h"
#import "FxClearChache.h"
#import "FxDate.h"
#import "FxDBManager.h"
@interface AppDelegate ()

@end

@implementation AppDelegate
+ (AppDelegate *)myAppDelegate
{
    return [UIApplication sharedApplication].delegate;
}
- (void)showHomePage
{
    HomePage  *homePage = [[HomePage alloc]init];
    self.window.rootViewController = homePage;
    [self.window makeKeyAndVisible];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    WMCommon *common = [WMCommon getInstance];
    common.screenW = [[UIScreen mainScreen] bounds].size.width;
    common.screenH = [[UIScreen mainScreen] bounds].size.height;

    self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
    [self showHomePage];
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
}
- (void)applicationWillTerminate:(UIApplication *)application
{
    NSArray *array = [FxDBManager fetchChacheComments];
    NSDate *nowDate = [NSDate date];
    for (NSString *date in array) {
        NSLog(@"%f",[nowDate timeIntervalSinceDate :[FxDate dateFromStringYMDHMS:date]]);
        if ([nowDate timeIntervalSinceDate :[FxDate dateFromStringYMDHMS:date]] > 12*3600.0) {
          [FxDBManager delectChacheCommnets:date];
        }
    }
    
    
}

@end
